//
//  DownloadImageOperation.m
//  LO_MUSIC
//
//  Created by lanou3g on 16/2/25.
//  Copyright © 2016年 杨少锋. All rights reserved.
//

#import "DownloadImageOperation.h"

@implementation DownloadImageOperation


//如果自定义线程,重写main函数

- (void)main {
    
    
    //子线程
    @autoreleasepool {
        
        //下载图片
        NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:self.url]];
        UIImage *image = [UIImage imageWithData:data];
        if (self.delegate && [self.delegate respondsToSelector:@selector(getImage:opreation:)]) {
            
            //回到主线程
            
            dispatch_async(dispatch_get_main_queue(), ^{
                
                [self.delegate getImage:image opreation:self];
                
            });
            
            
        }

        
    }
    
    
}

@end
